//
//  Dialog.swift
//  LiteAccount
//
//  Created by 刘伟 on 2017/5/26.
//  Copyright © 2017年 刘伟. All rights reserved.
//

import Foundation

class Dialog {
    static func alert(title: String, message: String) -> PopupDialog {
        let popup = PopupDialog(title: title, message: message,buttonAlignment: .horizontal, transitionStyle: .zoomIn, gestureDismissal: true)
        let btnCancel = CancelButton(title: "取消") {}
        popup.addButtons([btnCancel])
        return popup
    }
}

func confirmDialog(title: String?, message: String, sure: @escaping () -> Void ) -> PopupDialog {
    let popup = PopupDialog(title: title, message: message,buttonAlignment: .horizontal, transitionStyle: .zoomIn, gestureDismissal: true)
    let btnCancel = CancelButton(title: "取消") {}
    let btnSure = DefaultButton(title: "确认") {
        sure()
    }
    popup.addButtons([btnCancel, btnSure])
    return popup
}

func confirmDialog(title: String?, message: String, sure: @escaping () -> Void, cancle: @escaping () -> Void ) -> PopupDialog {
    let popup = PopupDialog(title: title, message: message,buttonAlignment: .horizontal, transitionStyle: .zoomIn, gestureDismissal: false)
    let btnCancel = CancelButton(title: "取消") {
        cancle()
    }
    let btnSure = DefaultButton(title: "确认") {
        sure()
    }
    popup.addButtons([btnCancel, btnSure])
    return popup
}


func confirmDialogWithText(title: String?, message: String, cancelText: String?, sureText: String?, sure: @escaping () -> Void ) -> PopupDialog {
    let popup = PopupDialog(title: title, message: message,buttonAlignment: .horizontal, transitionStyle: .zoomIn, gestureDismissal: true)
    let btnCancel = CancelButton(title: cancelText ?? "取消") {}
    let btnSure = DefaultButton(title: sureText ?? "确认") {
        sure()
    }
    popup.addButtons([btnCancel, btnSure])
    return popup
}

func alertDialog(title: String?, message: String) -> PopupDialog {
    let popup = PopupDialog(title: title, message: message, buttonAlignment: .horizontal, transitionStyle: .zoomIn, gestureDismissal: true)
    let btn = CancelButton(title: "确认") {}
    popup.addButtons([btn])
    return popup
}
